import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// @ts-ignore
import pkg from './package.json'
import { resolve } from 'path'

export default defineConfig({
	css: {
		preprocessorOptions: {
			less: {
				javascriptEnabled: true,
			},
		},
	},
	plugins: [
		vue({
			script: {
				// @ts-ignore
				defineModel: true,
			},
		}),
		vueJsx(),
	],
	build: {
		lib: {
			entry: 'src/index.ts',
			name: 'DmyAntd',
			fileName: format => `index.${format}.js`,
		},
		emptyOutDir: true,
		rollupOptions: {
			external: ['vue', 'vue-router', 'dayjs', '@idmy/core', 'ant-design-vue', 'lodash-es'],
			output: {
				globals: {
					'vue-router': 'VueRouter',
					vue: 'Vue',
				},
			},
		},
	},
	resolve: {
		alias: {
			'@': resolve(__dirname, '.', 'test'),
			'#': resolve(__dirname, '.', 'src'),
		},
	},
})
